package per.jerry.flightinformation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import per.jerry.flightinformation.entity.FlightTickets;
import per.jerry.flightinformation.entity.Flights;
import per.jerry.flightinformation.mapper.AirportMapper;
import per.jerry.flightinformation.mapper.FlightMapper;
import per.jerry.flightinformation.mapper.FlightTicketMapper;
import per.jerry.flightinformation.service.FlightService;

@Service("flightService")
public class FlightServiceImpl implements FlightService {
	
	@Autowired
	private FlightMapper flightMapper;
	@Autowired
	private AirportMapper airportMapper;
	@Autowired
	private FlightTicketMapper flightTicketMapper;
	
	/**
	 * 根据条件查询航班信息
	 * @param date
	 * @param takeCityName
	 * @param landingCityName
	 * @return
	 */
	public List<Flights> findFlightsByParams(String date, String takeCityName,
			String landingCityName){
		return flightMapper.findByParams(date, takeCityName, landingCityName);
	}
	
	/**
	 * 根据航班编号获取机票列表
	 * @param flightId
	 * @return
	 */
	public List<FlightTickets> findTicketsByFlightId(int flightId){
		return flightTicketMapper.findTicketsByFlightId(flightId);
	}


	public FlightMapper getFlightMapper() {
		return flightMapper;
	}

	public void setFlightMapper(FlightMapper flightMapper) {
		this.flightMapper = flightMapper;
	}

	public AirportMapper getAirportMapper() {
		return airportMapper;
	}

	public void setAirportMapper(AirportMapper airportMapper) {
		this.airportMapper = airportMapper;
	}

	public FlightTicketMapper getFlightTicketMapper() {
		return flightTicketMapper;
	}

	public void setFlightTicketMapper(FlightTicketMapper flightTicketMapper) {
		this.flightTicketMapper = flightTicketMapper;
	}

	@Override
	public void saveFlightTicket(FlightTickets ft) {
		flightTicketMapper.save(ft);
	}
	
	
}
